/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.fandi.view;

import com.fandi.controller.TransactionController;
import com.fandi.listener.TransactionOutListener;
import com.fandi.model.CustomerModel;
import com.fandi.model.ItemModel;
import com.fandi.model.TransactionDetailOutTableModel;
import com.fandi.model.TransactionOutModel;
import com.fandi.model.TransactionOutTableModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JSpinner;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JTextField;

/**
 *
 * @author Fandy
 */
public class TransFrame extends javax.swing.JInternalFrame implements TransactionOutListener {

    private static TransFrame transFrame;
            
    private ItemModel itemModel;
    private CustomerModel customerModel;
    private TransactionController controller;
    
    private TransactionOutModel transOutModel;
    private TransactionOutTableModel transOutTableModel;
    private TransactionDetailOutTableModel transactionDetailOutTableModel;
    
    /**
     * Creates new form CategoryFrame
     */
    public TransFrame() {
        initComponents();
        
        itemModel                       = new ItemModel();
        customerModel                   = new CustomerModel();
        transOutModel                   = new TransactionOutModel();
        transOutTableModel              = new TransactionOutTableModel();
        transactionDetailOutTableModel  = new TransactionDetailOutTableModel();
        
        transOutModel.setListener(this);
        
        controller = new TransactionController();
        controller.setItemModel(itemModel);
        controller.setCustomerModel(customerModel);
        
        controller.populateItems(this);
//        controller.populateCustomers(this);
        
        controller.setTransactionOutModel(transOutModel);
        controller.setTransOutTableModel(transOutTableModel);
        controller.setTransDetailOutTableModel(transactionDetailOutTableModel);
        controller.renderTableTransOut(this, false, null);
        controller.renderTableDetailTransOut(this, null);
        
        controller.generateTransCode(this);
        controller.setTotalRecords(this);
    }

    public static TransFrame getInstance() {
        if (transFrame == null) {
            transFrame = new TransFrame();
        }
        
        return transFrame;
    }

    public JComboBox getCmbTransOutItem() {
        return cmbTransOutItem;
    }

    public JLabel getLblTransOutTotalRecords() {
        return lblTransOutTotalRecords;
    }

    public JTable getTbTransDetailOutData() {
        return tbTransDetailOutData;
    }

    public JTable getTbTransOutData() {
        return tbTransOutData;
    }

    public JButton getTxtTransOutAddItem() {
        return txtTransOutAddItem;
    }

    public JTextField getTxtTransOutCode() {
        return txtTransOutCode;
    }

    public JTextArea getTxtTransOutDesc() {
        return txtTransOutDesc;
    }

    public JTextField getTxtTransOutDestination() {
        return txtTransOutDestination;
    }

    public JSpinner getTxtTransOutQty() {
        return txtTransOutQty;
    }

    public JTextField getTxtTransOutSearch() {
        return txtTransOutSearch;
    }

    public JButton getBtnTransOutRemoveItem() {
        return btnTransOutRemoveItem;
    }
    
    
    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel4 = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        tbTransDetailOutData = new javax.swing.JTable();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        txtTransOutCode = new javax.swing.JTextField();
        jScrollPane4 = new javax.swing.JScrollPane();
        txtTransOutDesc = new javax.swing.JTextArea();
        txtTransOutAddItem = new javax.swing.JButton();
        txtTransOutQty = new javax.swing.JSpinner();
        btnTransOutSave = new javax.swing.JButton();
        btnTransOutReset = new javax.swing.JButton();
        btnTransOutRemove = new javax.swing.JButton();
        btnTransOutRemoveItem = new javax.swing.JButton();
        cmbTransOutItem = new JComboBox<ItemModel>();
        txtTransOutDestination = new javax.swing.JTextField();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tbTransOutData = new javax.swing.JTable();
        jPanel6 = new javax.swing.JPanel();
        txtTransOutSearch = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        lblTransOutTotalRecords = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jPanel5 = new javax.swing.JPanel();
        jPanel7 = new javax.swing.JPanel();
        jPanel8 = new javax.swing.JPanel();
        jPanel9 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        tblItemData1 = new javax.swing.JTable();
        jPanel10 = new javax.swing.JPanel();
        txtSearch1 = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        lblTotalItems1 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();

        setClosable(true);
        setIconifiable(true);
        setTitle("Transaction");
        setPreferredSize(new java.awt.Dimension(920, 640));

        jPanel4.setLayout(new java.awt.BorderLayout());

        jPanel1.setPreferredSize(new java.awt.Dimension(887, 360));

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Order Form"));

        tbTransDetailOutData.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tbTransDetailOutData.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tbTransDetailOutDataMouseClicked(evt);
            }
        });
        jScrollPane3.setViewportView(tbTransDetailOutData);

        jLabel1.setText("Transaction Code");
        jLabel1.setPreferredSize(new java.awt.Dimension(120, 14));

        jLabel2.setText("Destination");

        jLabel3.setText("Item (Type to view)");

        jLabel5.setText("Note");

        txtTransOutCode.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        txtTransOutCode.setEnabled(false);
        txtTransOutCode.setPreferredSize(new java.awt.Dimension(250, 20));

        txtTransOutDesc.setColumns(20);
        txtTransOutDesc.setRows(5);
        jScrollPane4.setViewportView(txtTransOutDesc);

        txtTransOutAddItem.setText("Add");
        txtTransOutAddItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtTransOutAddItemActionPerformed(evt);
            }
        });

        txtTransOutQty.setValue(1);
        txtTransOutQty.setPreferredSize(new java.awt.Dimension(50, 20));

        btnTransOutSave.setText("Save Changes");
        btnTransOutSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTransOutSaveActionPerformed(evt);
            }
        });

        btnTransOutReset.setText("Reset");
        btnTransOutReset.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTransOutResetActionPerformed(evt);
            }
        });

        btnTransOutRemove.setText("Remove");
        btnTransOutRemove.setEnabled(false);

        btnTransOutRemoveItem.setText("Remove");
        btnTransOutRemoveItem.setEnabled(false);
        btnTransOutRemoveItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTransOutRemoveItemActionPerformed(evt);
            }
        });

        cmbTransOutItem.setToolTipText("Type to search more...");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(btnTransOutRemoveItem)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 400, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(jLabel3)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel3Layout.createSequentialGroup()
                                        .addComponent(txtTransOutQty, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(txtTransOutAddItem, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                    .addComponent(cmbTransOutItem, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addGap(117, 117, 117)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 18, Short.MAX_VALUE)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(jLabel5)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel3Layout.createSequentialGroup()
                                        .addComponent(btnTransOutSave)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(btnTransOutReset)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(btnTransOutRemove))
                                    .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 307, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(jLabel2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(txtTransOutDestination, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(txtTransOutCode, javax.swing.GroupLayout.PREFERRED_SIZE, 307, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addContainerGap())
        );

        jPanel3Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel1, jLabel2, jLabel3, jLabel5});

        jPanel3Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jScrollPane4, txtTransOutCode, txtTransOutDestination});

        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(cmbTransOutItem, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtTransOutQty, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtTransOutAddItem))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 192, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtTransOutCode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2)
                            .addComponent(txtTransOutDestination, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel5)
                            .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(btnTransOutSave)
                            .addComponent(btnTransOutReset)
                            .addComponent(btnTransOutRemove))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btnTransOutRemoveItem)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(23, Short.MAX_VALUE))
        );

        jPanel4.add(jPanel1, java.awt.BorderLayout.PAGE_START);

        jPanel2.setBorder(javax.swing.BorderFactory.createEmptyBorder(10, 10, 10, 10));
        jPanel2.setPreferredSize(new java.awt.Dimension(669, 250));
        jPanel2.setLayout(new java.awt.BorderLayout());

        tbTransOutData.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tbTransOutData.setToolTipText("Right Click to Edit");
        tbTransOutData.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tbTransOutDataMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(tbTransOutData);

        jPanel2.add(jScrollPane1, java.awt.BorderLayout.CENTER);

        jPanel6.setPreferredSize(new java.awt.Dimension(758, 40));

        txtTransOutSearch.setPreferredSize(new java.awt.Dimension(200, 20));

        jLabel7.setText("Search");

        lblTransOutTotalRecords.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        lblTransOutTotalRecords.setText("0");

        jLabel11.setText("Total Data");

        jLabel12.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        jLabel12.setForeground(new java.awt.Color(153, 153, 153));
        jLabel12.setText("Enter Transaction code to search");

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addComponent(jLabel7)
                .addGap(18, 18, 18)
                .addComponent(txtTransOutSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 162, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 373, Short.MAX_VALUE)
                .addComponent(jLabel11)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(lblTransOutTotalRecords)
                .addContainerGap())
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtTransOutSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7)
                    .addComponent(lblTransOutTotalRecords)
                    .addComponent(jLabel11)
                    .addComponent(jLabel12))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel2.add(jPanel6, java.awt.BorderLayout.PAGE_START);

        jPanel4.add(jPanel2, java.awt.BorderLayout.PAGE_END);

        jTabbedPane1.addTab("Transaction Out", jPanel4);

        jPanel5.setLayout(new java.awt.BorderLayout());

        jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder("Sales Form"));

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 855, Short.MAX_VALUE)
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 253, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel5.add(jPanel7, java.awt.BorderLayout.PAGE_START);

        jPanel9.setBorder(javax.swing.BorderFactory.createEmptyBorder(10, 10, 10, 10));
        jPanel9.setPreferredSize(new java.awt.Dimension(669, 250));
        jPanel9.setLayout(new java.awt.BorderLayout());

        tblItemData1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tblItemData1.setToolTipText("Right Click to Edit");
        tblItemData1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tblItemData1MouseClicked(evt);
            }
        });
        jScrollPane2.setViewportView(tblItemData1);

        jPanel9.add(jScrollPane2, java.awt.BorderLayout.CENTER);

        jPanel10.setPreferredSize(new java.awt.Dimension(758, 40));

        txtSearch1.setPreferredSize(new java.awt.Dimension(200, 20));

        jLabel8.setText("Search");

        lblTotalItems1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        lblTotalItems1.setText("0");

        jLabel13.setText("Total Data");

        jLabel14.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        jLabel14.setForeground(new java.awt.Color(153, 153, 153));
        jLabel14.setText("Enter Transaction code to search");

        javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10);
        jPanel10.setLayout(jPanel10Layout);
        jPanel10Layout.setHorizontalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addComponent(jLabel8)
                .addGap(18, 18, 18)
                .addComponent(txtSearch1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 162, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 373, Short.MAX_VALUE)
                .addComponent(jLabel13)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(lblTotalItems1)
                .addContainerGap())
        );
        jPanel10Layout.setVerticalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtSearch1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8)
                    .addComponent(lblTotalItems1)
                    .addComponent(jLabel13)
                    .addComponent(jLabel14))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel9.add(jPanel10, java.awt.BorderLayout.PAGE_START);

        jPanel5.add(jPanel9, java.awt.BorderLayout.PAGE_END);

        jTabbedPane1.addTab("Transaction In", jPanel5);

        getContentPane().add(jTabbedPane1, java.awt.BorderLayout.CENTER);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void tbTransOutDataMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tbTransOutDataMouseClicked
//        controller.selectItem(this);
    }//GEN-LAST:event_tbTransOutDataMouseClicked

    private void tblItemData1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblItemData1MouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_tblItemData1MouseClicked

    private void txtTransOutAddItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtTransOutAddItemActionPerformed
        // TODO add your handling code here:
        controller.getItem(this);
        controller.addOutItem(this);
    }//GEN-LAST:event_txtTransOutAddItemActionPerformed

    private void btnTransOutRemoveItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTransOutRemoveItemActionPerformed
        // TODO add your handling code here:
        controller.removeOutItem(this);
    }//GEN-LAST:event_btnTransOutRemoveItemActionPerformed

    private void tbTransDetailOutDataMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tbTransDetailOutDataMouseClicked
        // TODO add your handling code here:
        btnTransOutRemoveItem.setEnabled(true);
    }//GEN-LAST:event_tbTransDetailOutDataMouseClicked

    private void btnTransOutSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTransOutSaveActionPerformed
        // TODO add your handling code here:
        controller.insertDetail(this);
    }//GEN-LAST:event_btnTransOutSaveActionPerformed

    private void btnTransOutResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTransOutResetActionPerformed
        // TODO add your handling code here:
        controller.reset(this);
    }//GEN-LAST:event_btnTransOutResetActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnTransOutRemove;
    private javax.swing.JButton btnTransOutRemoveItem;
    private javax.swing.JButton btnTransOutReset;
    private javax.swing.JButton btnTransOutSave;
    private javax.swing.JComboBox cmbTransOutItem;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JLabel lblTotalItems1;
    private javax.swing.JLabel lblTransOutTotalRecords;
    private javax.swing.JTable tbTransDetailOutData;
    private javax.swing.JTable tbTransOutData;
    private javax.swing.JTable tblItemData1;
    private javax.swing.JTextField txtSearch1;
    private javax.swing.JButton txtTransOutAddItem;
    private javax.swing.JTextField txtTransOutCode;
    private javax.swing.JTextArea txtTransOutDesc;
    private javax.swing.JTextField txtTransOutDestination;
    private javax.swing.JSpinner txtTransOutQty;
    private javax.swing.JTextField txtTransOutSearch;
    // End of variables declaration//GEN-END:variables

    @Override
    public void onChange(TransactionOutModel model) {
        txtTransOutCode.setText(model.getTransCode());
        txtTransOutDestination.setText(model.getDestination());
        txtTransOutDesc.setText(model.getDescription());
    }
}
